<script setup>
import { ref } from 'vue';

// 顶部四个功能项数据
const functionItems = ref([
  {
    name: '好友',
    icon: require('@/assets/images//friend.png'), // 替换为你的本地图片路径
    unread: 0
  },
  {
    name: '粉丝',
    icon: require('@/assets/images/fan.png'), // 替换为你的本地图片路径
    unread: 0
  },
  {
    name: '点赞',
    icon: require('@/assets/images/like.png'), // 替换为你的本地图片路径
    unread: 0
  },
  {
    name: '收藏',
    icon: require('@/assets/images/star.png'), // 替换为你的本地图片路径
    unread: 100
  }
]);
</script>

<template>
  <van-nav-bar :title="$route.name">
    <template #right>
      <van-icon name="search" size="18"/>
    </template>
  </van-nav-bar>

  <div class="social-container">
    <!-- 顶部四个功能入口 -->
    <div class="function-grid">
      <div
          v-for="item in functionItems"
          :key="item.name"
          class="function-item"
      >
        <van-badge :content="item.unread" :show-zero="true">
          <div class="function-icon">
            <img :src="item.icon" />
          </div>
        </van-badge>
        <div class="function-name">{{ item.name }}</div>
      </div>
    </div>


    <!-- 聊天室列表 -->
    <div class="chat-room-list">
      <!-- 常驻的homie大厅 -->
      <div class="chat-room-item" @click="$router.push('/message/chat')">
        <div class="room-avatar">
          <img src="@/assets/images/record.png" />
        </div>
        <div class="room-info">
          <div class="room-name">homie大厅</div>
          <div class="room-message">官方聊天室</div>
        </div>
        <van-tag type="primary" class="room-tag">官方</van-tag>
      </div>

      <!-- 个人账号 -->
      <div class="chat-room-item">
        <div class="room-avatar">
          <img src="@/assets/images/record.png" />
        </div>
        <div class="room-info">
          <div class="room-name">9999</div>
          <div class="room-message">15556</div>
        </div>
        <van-tag type="primary" class="room-tag">个人</van-tag>
      </div>

    </div>
  </div>
</template>



<style scoped>
.social-container {
  padding: 16px;
  background-color: white;
}

.function-grid {
  display: flex;
  justify-content: space-around;
  margin-bottom: 20px;
}

.function-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.function-icon {
  width: 40px;
  height: 40px;
  margin-bottom: 8px;
}

.function-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.function-name {
  font-size: 14px;
  color: #333;
}

.message-section {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background-color: #f7f8fa;
  border-radius: 8px;
  margin-bottom: 20px;
}

.message-icon {
  width: 24px;
  height: 24px;
  margin-right: 12px;
}

.message-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.message-text {
  font-size: 16px;
  color: #333;
}

.chat-room-list {
  border-radius: 8px;
  overflow: hidden;
}

.chat-room-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background-color: #fff;
  border-bottom: 1px solid #f5f5f5;
}

.room-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin-right: 12px;
  overflow: hidden;
}

.room-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.room-info {
  flex: 1;
}

.room-name {
  font-size: 16px;
  color: #333;
  margin-bottom: 4px;
}

.room-message {
  font-size: 12px;
  color: #999;
}

.room-tag {
  margin-left: 8px;
}
</style>
